﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MyDemos
{

    public abstract class NokiaMapsTileSourceBase : Microsoft.Phone.Controls.Maps.TileSource
    {
        protected NokiaMapsTileSourceBase (string uriFormat)
            : base (uriFormat)
        {
        }

        static int _tile_count = 0;

        static string token = "vWfKwUBTTqKoDStbqmGA";
        static string appId = "4Pmgi786zawEUkhrWmr6";

        public override System.Uri GetUri (int x, int y, int zoomLevel)
        {
            return new System.Uri (
                string.Format (
                    UriFormat,
                    (_tile_count++ % 4) + 1,
                    zoomLevel,
                    x,
                    y,
                    token,
                    appId));
        }
    }

    /// <summary>  
    /// 地圖檢視  
    /// </summary>  
    public class NokiaMapsRoadTileSource : NokiaMapsTileSourceBase
    {
        public NokiaMapsRoadTileSource ()
            : base ("http://{0}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/normal.day/{1}/{2}/{3}/256/png8?lg=CHI&token={4}&appId={5}")
        {
        }
    }

    /// <summary>  
    /// 衛星檢視 ( Satellite View )  
    /// </summary>  
    public class NokiaMapsSatelliteTileSource : NokiaMapsTileSourceBase
    {
        public NokiaMapsSatelliteTileSource ()
            : base ("http://{0}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/hybrid.day/{1}/{2}/{3}/256/png8?lg=CHI&token={4}&appId={5}")
        {
        }
    }

    /// <summary>  
    /// 地形檢視 ( Terrain View )  
    /// </summary>  
    public class NokiaMapsTerrainTileSource : NokiaMapsTileSourceBase
    {
        public NokiaMapsTerrainTileSource ()
            : base ("http://{0}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/terrain.day/{1}/{2}/{3}/256/png8?lg=CHI&token={4}&appId={5}")
        {
        }
    }  
}
